#ifndef _RTT_DRV_PIN_H
#define _RTT_DRV_PIN_H

#include <rtdevice.h>
#include <rthw.h>
#include <rtthread.h>
#include "board.h"

#define __GD32_PIN(index, port, pin) {index, \
                                      RCU_GPIO##port, \
                                      GPIO##port, \
                                      GPIO_PIN_##pin, \
                                      GPIO_PORT_SOURCE_GPIO##port, \
                                      GPIO_PIN_SOURCE_##pin}

#define __GD32_PIN_DEFAULT {-1, (rcu_periph_enum)0, 0, 0, 0, 0}

struct pin_index
{
    int index;
    
    rcu_periph_enum clk;
    uint32_t gpio_periph;
    uint32_t pin;
    
    uint8_t port_src;
    uint8_t pin_src;
};

struct pin_irq_map
{
    rt_uint16_t pinbit;
    IRQn_Type irqno;
};

#endif
